﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xant.FlowEngine.Interface;

namespace Xant.FlowEngine.Core
{
    /// <summary>
    /// 抽象流程对象，所有对象的父类
    /// </summary>
    public abstract class AbstractFlowObject
    {
        /// <summary>
        /// 主键
        /// </summary>
        public Guid Id { get; set; }

        public bool Invalid { get; set; }

        /// <summary>
        /// 行版本，用于乐观锁控制并发
        /// </summary>
        public int RowVersion { get; set; }

        public RowState RowState { get; set; }

        //不再使用时间戳来做乐观锁控制并发，因为SQL SERVER和MySQL中的时间戳格式是不一样的，无法做到通用
        //public byte[] TS { get; set; }

        public AbstractFlowObject()
        {
            this.Id = Utility.CombKey.Combine(Guid.NewGuid(), DBConnectionManager.ProviderType==ProviderType.SqlServer);
            this.RowVersion = 0;
            this.RowState = Interface.RowState.Added;
        }

    }

}
